#pragma once
#include "Port_Global.h"
#include <vector>
#include <string>

using namespace std;

typedef struct FileKeyMap
{
	DATAFILE *dataFile;
	string key;

} FileKeyMap;

class ResourceManager
{
public:
	ResourceManager(void);
	~ResourceManager(void);

	void loadGlobalResources();

	void loadDataFile(string fileName)
	{
		DATAFILE *dataFile = load_datafile(fileName.c_str());
		ASSERT(dataFile);
		FileKeyMap newFile;
		newFile.key = fileName;
		newFile.dataFile = dataFile;
		dataFiles.push_back(newFile);
	}

	void *getData(int key, string file)
	{
		for (vector<FileKeyMap>::const_iterator itr = dataFiles.begin(); itr < dataFiles.end(); ++itr)
		{
			FileKeyMap map = static_cast<FileKeyMap>(*itr);
			if(file == map.key)
			{
				return map.dataFile[key].dat;
			}
		}
		ASSERT(false);
		return NULL;
	}

	void unloadDataFile(string file)
	{
		for (vector<FileKeyMap>::const_iterator itr = dataFiles.begin(); itr < dataFiles.end(); ++itr)
		{
			FileKeyMap map = static_cast<FileKeyMap>(*itr);
			if(file == map.key)
			{
				unload_datafile(map.dataFile);
				dataFiles.erase(itr);
				return;
			}
		}
		ASSERT(false);
	}

	FONT *font;

	DATAFILE *GraphicPackA; 
	DATAFILE *Japanese_Fonts;

	static const int num_buttons = 6;
	Button buttons[num_buttons];

private:
	vector<FileKeyMap> dataFiles;
};
